// CIRCLE_PARAMETERS.cpp : Defines the entry point for the console application.
//

#ifdef _WIN32
#define _IS_WINDOWS 1
#endif

#define _USE_MATH_DEFINES = 1; // allows use of M_PI

#include "stdio.h" // for stdin and stdout
#include "math.h" // for M_PI
#include "stdlib.h" // for system()

void cls() {
	if(_IS_WINDOWS)
		system("cls");
	else
		system("clear"); // assume linux
}
int main(int argc, char *argv[]) {
	// init all variables
	double radius = 0;
	double circumference;
	double area;
	double total = 0; // radius total

	int i = 0; // counter
	
	while(radius != -1) {

		// welcome statement
		printf("\nEnter a radius (-1 to quit): ");

		if(scanf("%lf", &radius) != 1) { // scanf returns 1 if input matches %lf (double)
			
			system("cls");

			fflush(stdin); // clear input buffer
			printf("\nTry again... enter a valid number.\n");
	
		} else {

			system("cls");

			//some math, using long double to avoid precision and rounding errors
			circumference = 2 * M_PI * (long double) radius;
			area = pow((long double) radius, 2) * (long double) M_PI;
			printf("\nRadius: %.3lf: ", radius);
			printf("\nCircumference: %.3lf: ", circumference);
			printf("\nArea: %.3lf: ", area);
			total += radius; // increment total count
			i++; // increment calculations

			// "Total of n calculation(s) and total of radiuses is x"
			printf("\n\nTotal of %d calculation%s and total of radiuses is %.3lf\n", i, (i == 1) ? "" : "s", total);
		}
	}

	return 0;

}

